Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 14, 2025

Description

Adds unit test verifying that Spring Cloud Azure Service Bus JMS correctly configures CachingConnectionFactory to cache and reuse MessageProducer and MessageConsumer instances for the same destination. Also updates the azure-servicebus-jms dependency to version 2.1.0.

Changes

  • New test: cachingConnectionFactoryCachesProducersAndConsumersForSameDestination in ServiceBusJmsConnectionFactoryConfigurationTests

    • Verifies isCacheProducers() returns true when cache properties are enabled
    • Verifies isCacheConsumers() returns true when cache properties are enabled
    • Parameterized for both standard and premium pricing tiers
  • Dependency update: Updated azure-servicebus-jms from 2.0.0 to 2.1.0 in:

    • eng/versioning/external_dependencies.txt
    • sdk/spring/spring-cloud-azure-autoconfigure/pom.xml
    • sdk/spring/spring-cloud-azure-starter-servicebus-jms/pom.xml

The test ensures Spring Framework's CachingConnectionFactory will cache producers/consumers as documented in CachingConnectionFactory.java#L362 and L427.

Fixes #47281

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.
Original prompt

This section details on the original issue you should resolve

<issue_title>[FEATURE REQ] Add UT for Spring Cloud Azure</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.
Add a new UT to make sure when using Spring Cloud Azure Service Bus JMS, with CachingConnectionFactory mode , the same object is always used when creating producers/consumers for the same destination.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
https://github.com/spring-projects/spring-framework/blob/92a186b44b4e58a9932c23fe71c243b5e944160a/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java#L362

https://github.com/spring-projects/spring-framework/blob/92a186b44b4e58a9932c23fe71c243b5e944160a/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java#L427

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Description Added
  • Expected solution specified
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…nFactory behavior

Verify that when using CachingConnectionFactory mode, producer and consumer
caching is properly configured for reusing MessageProducer and MessageConsumer
instances for the same destination.

Test covers both standard and premium pricing tiers.

Co-authored-by: Netyyyy <[email protected]>
Copilot AI changed the title [WIP] Add unit test for Spring Cloud Azure Service Bus JMS Add unit test for CachingConnectionFactory producer/consumer reuse in Spring Cloud Azure Service Bus JMS Nov 14, 2025
Copilot AI requested a review from Netyyyy November 14, 2025 09:26
Copilot finished work on behalf of Netyyyy November 14, 2025 09:26
@Netyyyy Netyyyy requested a review from Copilot November 24, 2025 02:29
Copilot finished reviewing on behalf of Netyyyy November 24, 2025 02:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a unit test to verify that Spring Cloud Azure Service Bus JMS correctly configures CachingConnectionFactory to enable caching of MessageProducer and MessageConsumer instances when the appropriate cache properties are set.

Key Changes:

  • Adds parameterized test cachingConnectionFactoryCachesProducersAndConsumersForSameDestination covering both standard and premium pricing tiers
  • Verifies that CachingConnectionFactory.isCacheProducers() and isCacheConsumers() return true when configured with cache properties

Comment on lines 156 to 161

ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class);

CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory;

Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove this extra blank line to maintain consistency with the rest of the test file. Other tests in this file do not have blank lines between assertions within the same test method.

Suggested change
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class);
CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory;
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class);
CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory;

Copilot uses AI. Check for mistakes.
assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class);

CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory;

Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove this blank line to maintain consistency with the rest of the test file. Other tests in this file do not have blank lines between assertions.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines 157 to 161
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class);

CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory;

Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Simplify bean retrieval and casting. Since line 155 already asserts that a CachingConnectionFactory bean exists, these lines can be simplified to:

CachingConnectionFactory cachingFactory = context.getBean(CachingConnectionFactory.class);

This eliminates the intermediate ConnectionFactory variable and the redundant isInstanceOf assertion.

Suggested change
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
assertThat(connectionFactory).isInstanceOf(CachingConnectionFactory.class);
CachingConnectionFactory cachingFactory = (CachingConnectionFactory) connectionFactory;
CachingConnectionFactory cachingFactory = context.getBean(CachingConnectionFactory.class);

Copilot uses AI. Check for mistakes.
@Netyyyy
Copy link
Member

Netyyyy commented Dec 1, 2025

@copilot update azure-servicebus-jms verion to 2.1.0 and make sure the ut test reusing the same producer for one dest

- Updated azure-servicebus-jms version from 2.0.0 to 2.1.0 in:
  - eng/versioning/external_dependencies.txt
  - sdk/spring/spring-cloud-azure-autoconfigure/pom.xml
  - sdk/spring/spring-cloud-azure-starter-servicebus-jms/pom.xml
- Simplified test code per review feedback:
  - Removed unnecessary blank lines
  - Simplified bean retrieval by getting CachingConnectionFactory directly
  - Removed unused imports
- Test verifies that CachingConnectionFactory caches producers/consumers
  for the same destination when configured with appropriate properties

Co-authored-by: Netyyyy <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 1, 2025

@copilot update azure-servicebus-jms verion to 2.1.0 and make sure the ut test reusing the same producer for one dest

Updated azure-servicebus-jms to version 2.1.0 and simplified the test code per review feedback. The test now verifies that CachingConnectionFactory.isCacheProducers() and isCacheConsumers() return true when configured, which ensures Spring Framework's CachingConnectionFactory will cache and reuse MessageProducer/MessageConsumer instances for the same destination. Addressed in commit 8c13386.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • oss.jfrog.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring org.codehaus.plexus.classworlds.launcher.Launcher clean install -DskipTests -Dspotless.skip=true -Dcodesnippet.skip=true -Dcheckstyle.skip=true -Drevapi.skip=true -T 1C (dns block)
  • test-namespace.servicebus.windows.net
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -javaagent:/home/REDACTED/.m2/repository/org/jacoco/org.jacoco.agent/0.8.13/org.jacoco.agent-0.8.13-runtime.jar=destfile=/home/REDACTED/work/azure-sdk-for-java/azure-sdk-for-java/sdk/spring/spring-cloud-azure-autoconfigure/target/jacoco-unit.exec,excludes=MET (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add unit test for CachingConnectionFactory producer/consumer reuse in Spring Cloud Azure Service Bus JMS Add unit test for CachingConnectionFactory producer/consumer reuse and update azure-servicebus-jms to 2.1.0 Dec 1, 2025
Copilot finished work on behalf of Netyyyy December 1, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQ] Add UT for Spring Cloud Azure

2 participants